package com.estudy.entity;

/**
 * @author: yi.jianhua
 * @create: 2019/08/08 18:05
 */
public enum RoleEnum {
    /**
     * 管理员
     */
    ADMIN(0, "管理员"),
    /**
     * 审核人员
     */
    AUDITORS(1, "审核人员"),
    /**
     * 普通人员
     */
    NORMAL(2, "普通人员");
    private int code;
    private String name;

    RoleEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static RoleEnum getEnumByCode(int code) {
        RoleEnum[] values = RoleEnum.values();
        for (RoleEnum roleEnum : values) {
            if (roleEnum.code == code) {
                return roleEnum;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "RoleEnum{" +
                "code=" + code +
                ", name='" + name + '\'' +
                '}';
    }
}
